// createRouter 可执行函数，产出一个router路由实例对象
// createWebHistory 可执行函数，产出hash模式路由
import { createRouter, createWebHashHistory } from 'vue-router'
import Layout from '@/views/Layout'
import Home from '@/views/Home'
import Play from '@/views/Playground'
import Category from '@/views/Category'
import SubCategory from '@/views/Category/Sub/index.vue'
import Goods from '@/views/Goods'
import Login from '@/views/Login/index.vue'
// const LoginCallBack = () => import('@/views/Login/components/callback.vue')
import CallBack from '@/views/Login/components/callback.vue'
import Cart from '@/views/Cart/index.vue'

const routes = [
  {
    path: '/',
    component: Layout,
    children: [
      {
        path: '/',
        component: Home
      },
      {
        path: '/category/:id',
        component: Category
      },
      {
        path: '/subCategory/:id',
        component: SubCategory
      },
      {
        path: '/good/:id',
        component: Goods
      },
      {
        path: '/cart',
        component: Cart
      }
    ]
  },
  {
    path: '/play',
    component: Play
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/login/callback',
    // component: () => import('@/views/Login/components/callback.vue')
    component: CallBack
  }
]
// createRouter 创建一个路由实例
// createWebHistory history配置
const router = createRouter({
  history: createWebHashHistory(process.env.BASE_URL),
  routes
})

export default router
